#pragma once
#include <iostream>
#include <functional>
#include "InetAddr.hpp"
//#include "Reactor.hpp"


class Reactor;//声明

using handler_t = std::function<std::string (std::string &)>;
class Connection
{
public:
    Connection()
    :_events(-1),
     _owner(nullptr)
    {

    }
    void SetEvent(const uint32_t& event)//不加const和取地址好像也没什么影响
    {
        _events = event;
    }

    uint32_t GetEvent()
    {
        return _events;
    }

    void SetOwner(Reactor* owner)
    {
        _owner = owner;
    }
    Reactor* GetOwner()
    {
        return _owner;
    }

    void SetFunction(handler_t handler)
    {
        _handler = handler;
    }
    virtual int GetSockFd() = 0;
    virtual void Recver() = 0;
    virtual void Sender() = 0;
    virtual void Excepter() = 0;
    ~Connection()
    {
        
    }
private:
    uint32_t _events; //文件描述符的关心事件

    Reactor *_owner;//回指指针(指向管理容器)
public:
    handler_t _handler;
};